#ifndef __System_Array_Core_H__
#define __System_Array_Core_H__

//+ ThunkC Keywords
typedef void* Array;
	#define array_getLength(t) *((int_*)t-1)
	#define newArray(t,Ti,length) (Ti*)((int*)malloc(sizeof(Ti)*length+4)+1);*((int*)t-1)=length
	#define freeArray(t) free((int*)t-1)
#define localArray(length,...) int_ x = length; __VA_ARGS__
#define fieldArray(length,...) int_ x = length; __VA_ARGS__

///<summary>
/// GetEnumerable<T>
///</summary>
#define array_getEnumerable(T,...) spaceT(array,T,getEnumerable)(__VA_ARGS__)
#define array_Declare_GetEnumerable(T, Ti) \
	public static_ Collections_IEnumerable(T) *spaceT(array,T,getEnumerable)(Array array);
#define array_Implement_GetEnumerable(T, Ti) \
	/*[ getEnumerable ] */ \
	public __device__ static_ Collections_IEnumerable(T) *spaceT(array,T,getEnumerable)(Array array) \
	{ \
		System_Array(T) *array2 = new(,System_Array(T), array); \
		return as(array2, Collections_IEnumerable(T)); \
	}

/////<summary>
///// GetEnumerator<T>
/////</summary>
//#define array_getEnumerator(T,...) spaceT(array,T,getEnumerator)(__VA_ARGS__)
//#define array_Declare_GetEnumerator(T, Ti) \
//	public static_ Collections_IEnumerator(T) *spaceT(array,T,getEnumerator)(Array array);
//#define array_Implement_GetEnumerator(T, Ti) \
//	/*[ getEnumerator ] */ \
//	public __device__ static_ Collections_IEnumerator(T) *spaceT(array,T,getEnumerator)(Array array) \
//	{ \
//		System_ArrayXSZArrayEnumerator(T) *arrayEnumerator = newa(,System_ArrayXSZArrayEnumerator(T), array); \
//		return as(arrayEnumerator, Collections_IEnumerator(T)); \
//	}

#endif /* __System_Array_Core_H__ */
